package kz.pompei.ifacer.util;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;

import javax.imageio.ImageIO;

import kz.pompei.ifacer.dialogs.FontUtil;

public class RichTextTester {
  public static void main(String[] args) throws Exception {
    int w = 1800, h = 600;
    BufferedImage im = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    
    Graphics2D g = FontUtil.prepare(im.getGraphics());
    
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, w, h);
    
    int y = 70;
    
    {
      String txt = "{ftimes new roman/20}{c#ff00ee}~Привет~ /всем {c#119911}!!!/ _Hello *WORLD*!!!_";
      RichText rt = RichText.parse(txt);
      TextSize s = rt.getSize(g);
      rt.draw(g, 10, y + s.ascent, true);
      y += s.height();
    }
    {
      String txt = "{fubuntu condensed/27} Один начинается{s37} и продолжается"
          + "{s47} и ещё раз...";
      RichText rt = RichText.parse(txt);
      rt.setFontFamilyEverywhere("times new roman");
      TextSize s = rt.getSize(g);
      rt.draw(g, 10, y + s.ascent, true);
      y += s.height();
    }
    
    g.dispose();
    
    ImageIO.write(im, "png", new FileOutputStream("out/RichText.png"));
    
    System.out.println("Complete");
  }
}
